﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CJJCH.Web.Controls
{
    public partial class Top : System.Web.UI.UserControl
    {
        private int firstID;
        public int FirstID
        {
            get { return firstID; }
            set { firstID = value; }
        }
        private int secondId;
        public int SecondId
        {
            get { return secondId; }
            set { secondId = value; }
        }
        private string secondName;
        public string SecondName
        {
            get { return secondName; }
            set { secondName = value; }
        }
        private int _typeID;
        public int TypeID
        {
            get { return _typeID; }
            set { _typeID = value; }
        }
        private int _iIndex;
        public int IIndex
        {
            get { return _iIndex; }
            set { _iIndex = value; }
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitMenu();
                InitDataBinding();
            }           
        }
        private void InitMenu()
        {
            if (TypeID == 0)
            {
                Li3.Style.Add("display", "none");
            }
            else if (TypeID != 0)
            {
                Li3.Style.Add("display", "block");
                lnkThird.Text = secondName + "类别";
            }
            lnkName.Text = SecondName;
            switch (IIndex)
            {
                case 1:
                    Li1.Attributes.Add("class", "selectTag");
                    break;
                case 2:
                    Li2.Attributes.Add("class", "selectTag");
                    break;
                case 3:
                    Li3.Attributes.Add("class", "selectTag");
                    break;
                default:
                    break;
            }
        }
        private void InitDataBinding()
        {
            if (SecondId != 0 && !string.IsNullOrEmpty(SecondName))
            {
                lnkName.Text = SecondName + "列表";
                lnkAdd.Text = "添加" + secondName;
                lnkName.NavigateUrl = "~/Manage/ConsultingList.aspx?secondid=" + LTP.Common.StringClass.EncodeUrl(SecondId.ToString()) + "&secondname=" + LTP.Common.StringClass.EncodeUrl(SecondName) + "";
                lnkThird.NavigateUrl = "~/Manage/ConsultingType.aspx?secondid=" + LTP.Common.StringClass.EncodeUrl(SecondId.ToString()) + "&secondname=" + LTP.Common.StringClass.EncodeUrl(SecondName) + "";
                lnkAdd.NavigateUrl = "~/Manage/ConsultingAdd.aspx?secondid=" + LTP.Common.StringClass.EncodeUrl(SecondId.ToString()) + "&secondname=" + LTP.Common.StringClass.EncodeUrl(SecondName) + "";
            }
            else
            {
                LTP.Common.WindowClass.WindowBack("操作错误！");
            }
        }
    }
}